﻿using Framework.Common;
using System.Collections.Generic;

namespace Framework.Resource
{
    /// <summary>
    /// 资源管理接口
    /// </summary>
    public interface IResourceManager
    {
        /// <summary>
        /// 获取所有资源包的数量
        /// </summary>
        int AllAssetPackageCount
        {
            get;
        }
        /// <summary>
        /// 获得所有资源包的名称集合
        /// </summary>
        List<string> AllAssetPackageNameList
        {
            get;
        }
        /// <summary>
        /// 资源加载帮助对象
        /// </summary>
        IAssetHelper AssetHelper
        {
            get;
        }
        /// <summary>
        /// 加载资源包
        /// </summary>
        /// <param name="packageName">资源包名称</param>
        /// <returns>加载的资源包</returns>
        AssetPackage LoadPackage(string packageName);
        /// <summary>
        /// 加载资源包
        /// </summary>
        /// <param name="packageName">资源包名称</param>
        /// <param name="loadStartCallback">开始加载回调</param>
        /// <param name="loadSuccessCallback">加载成功回调</param>
        /// <param name="loadFailureCallBack">加载失败回调</param>
        /// <param name="loadUpdateCallback">加载更新回调</param>
        void LoadPackageAsync(string packageName, FrameworkAction<string> loadStartCallback, FrameworkAction<string, AssetPackage> loadSuccessCallback, FrameworkAction<string, string> loadFailureCallBack, FrameworkAction<string, int> loadUpdateCallback);
        /// <summary>
        /// 释放资源包
        /// </summary>
        /// <param name="packageName">资源包名称</param>
        /// <param name="isForce">是否强制释放</param>
        void ReleasePackage(string packageName, bool isForce);
        /// <summary>
        /// 加载资源
        /// </summary>
        /// <typeparam name="T">资源类型</typeparam>
        /// <param name="assetPackageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        /// <returns>加载的资源</returns>
        T LoadAsset<T>(string assetPackageName, string assetName);
        /// <summary>
        /// 异步加载指定类型资源
        /// </summary>
        /// <param name="assetPackageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        /// <param name="loadStartCallback">加载资源开始回调</param>
        /// <param name="LoadSuccessCallback">加载资源成功回调</param>
        /// <param name="loadFailureCallBack">加载资源失败回调</param>
        /// <param name="loadUpdateCallback">加载资源更新回调</param>
        void LoadAssetAsync<T>(string assetPackageName, string assetName, FrameworkAction<string, string> loadStartCallback, FrameworkAction<string, string, T> loadSuccessCallback, FrameworkAction<string, string, string> loadFailureCallBack, FrameworkAction<string, string, int> loadUpdateCallback);
        /// <summary>
        /// 释放指定资源
        /// </summary>
        /// <param name="assetPackageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        void ReleaseAsset(string assetPackageName, string assetName);
        /// <summary>
        /// 创建游戏对象
        /// </summary>
        /// <param name="assetPackageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        /// <returns>创建的游戏对象</returns>
        object CreateGameObject(string assetPackageName, string assetName);
        /// <summary>
        /// 异步创建游戏对象
        /// </summary>
        /// <param name="assetPackageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        /// <param name="loadStartCallback">创建游戏对象开始回调</param>
        /// <param name="LoadSuccessCallback">创建游戏对象成功回调</param>
        /// <param name="loadFailureCallBack">创建游戏对象失败回调</param>
        /// <param name="loadUpdateCallback">创建游戏对象更新回调</param>
        void CreateGameObjectAsyc(string assetPackageName, string assetName, FrameworkAction<string, string> loadStartCallback, FrameworkAction<string, string, object> loadSuccessCallback, FrameworkAction<string, string, string> loadFailureCallBack, FrameworkAction<string, string, int> loadUpdateCallback);
        /// <summary>
        /// 销毁一个游戏对象
        /// </summary>
        /// <param name="packageName">资源包名称</param>
        /// <param name="assetName">资源名称</param>
        /// <param name="gameObject">游戏对象</param>
        void DestroyGameObject(string packageName, string assetName, object gameObject);
        /// <summary>
        /// 释放没有用到的资源
        /// </summary>
        void ReleaseUnusedAssets();
        /// <summary>
        /// 释放所有的资源
        /// </summary>
        void ReleaseAllAssets();
        /// <summary>
        /// 添加资源帮助类
        /// </summary>
        /// <param name="helper">资源帮助对象</param>
        void AddAssetHelper(IAssetHelper helper);
        /// <summary>
        /// 添加资源加载代理器
        /// </summary>
        /// <param name="helper">资源加载接口</param>
        void AddLoadAssetAgent(ILoadAssetHelper helper);
    }
}
